<template>
  <div class="fu">
    <div class="left">
      <i class="el-icon-s-claim"></i>
      <span>信息维护</span>
    </div>
    <div style="clear: left"></div>
    <div class="wai-bord">
      <el-row id="form">
        <el-col :span="8" :offset="8">
          <el-form ref="form" label-width="80px" :model="form">
            <el-form-item label="学号">
              <el-input v-model="form.studentNumber" disabled></el-input>
            </el-form-item>
            <el-form-item label="姓名">
              <el-input v-model="form.studentName" disabled></el-input>
            </el-form-item>
            <el-form-item label="教学系">
              <el-input v-model="form.departmentName" disabled></el-input>
            </el-form-item>
            <el-form-item label="专业">
              <el-input v-model="form.majorName" disabled></el-input>
            </el-form-item>
            <el-form-item label="班级">
              <el-input v-model="form.className" disabled></el-input>
            </el-form-item>
            <el-form-item label="Email">
              <el-input v-model="form.studentEmail"></el-input>
            </el-form-item>
            <el-form-item label="生日">
              <el-input v-model="form.studentBirthday"></el-input>
            </el-form-item>
            <el-form-item label="性别">
              <el-radio-group v-model="form.studentSex">
                <el-radio :label="0">男</el-radio>
                <el-radio :label="1">女</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="密码">
              <el-input type="password" v-model="form.studentPassword"></el-input>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="onSubmit">更新</el-button>
            </el-form-item>
          </el-form>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
  import {deletefn, put,get, post} from "../../common/request";

  export default {
    name: "StudentSetting",
    data() {
      return {
        form: {
          studentNumber: "",
          studentName: "",
          departmentName: "",
          majorName: "",
          className: "",
          studentEmail: "",
          studentBirthday: "",
          studentSex: "",
          studentPassword: ""
        }
      }
    },

    mounted() {
      this.getAll();
    },
    methods: {
      onSubmit() {
        put("/student/updateStudentInfo", this.form).then(res => {
          if (res.code == 1) {
            this.$message.success(res.msg);
            this.getStudentInfo();
          } else {

            this.$message.error(res.msg);
          }
        })
      },
      getStudentInfo() {
        get("/student/getStudentInfo").then(res => {
          this.form = res.data;
        })
      }
    },
    mounted() {
      this.getStudentInfo();
    }

  }
</script>

<style scoped>

  .left {
    float: left;
    font-size: 14px;
    color: #606266;
    margin-bottom: 5px;
  }

  .wai-bord {
    background-color: white;
    border: #dcdfe6 solid 1px;
    border-radius: 3px;
    padding: 5px 15px;
  }

  .right {
    float: right;
  }
</style>
